/*
 * @Author: szx
 * @Date: 2022-03-06 15:03:18
 * @LastEditTime: 2022-03-06 15:10:55
 * @Description:
 * @FilePath: \leetcode\2100-2199\2100\2100.js
 */
/**
 * @param {number[]} security
 * @param {number} time
 * @return {number[]}
 */
var goodDaysToRobBank = function (security, time) {
    const n = security.length;
    const left = new Array(n).fill(0);
    const right = new Array(n).fill(0);
    for (let i = 1; i < n; i++) {
        if (security[i] <= security[i - 1]) left[i] = 1 + left[i - 1];
        if (security[n - i - 1] <= security[n - i]) right[n - i - 1] = 1 + right[n - i];
    }
    const res = [];
    for (let i = 0; i < n; i++) {
        if (left[i] >= time && right[i] >= time) res.push(i);
    }
    return res;
};
console.log(goodDaysToRobBank([5, 3, 3, 3, 5, 6, 2], 2));
console.log(goodDaysToRobBank([1, 1, 1, 1, 1], 0));
console.log(goodDaysToRobBank([1, 2, 3, 4, 5, 6], 2));
console.log(goodDaysToRobBank([1], 5));
